package com.whut.controller;

import com.whut.mapper.NewPrefixSystemMapper;
import com.whut.service.ActualMeasureService;
import com.whut.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;

@Controller
@RequestMapping("/report")
public class ReportController {
    @Resource
    private ReportService reportService;
    @Autowired
    private ActualMeasureService actualMeasureService;
    @Resource
    private NewPrefixSystemMapper newprefixsystemMapper;

    /**
     *
     * @param client (委托方Id)=>字符串数组
     * @param task (片区项目Id)=>字符串数组
     * @param check (检查Id)=>字符串数组
     * @param startTime  开始时间
     * @param endTime  结束时间
     * @return java.lang.Object
     * @author fanyu
     * @date 2019/9/5 20:24
     */
    @ResponseBody
    @PostMapping("/getAllCheckInfoForReport")
    public Object getAllCheckInfoForReport(String client, String task, String check, String startTime, String endTime) {
        return reportService.getAllCheckInfoForReport(client, task, check, startTime, endTime);
    }

    @ResponseBody
    @PostMapping("/getSecurityReport")
    public String getSecurityReport(String client,String check,String checkInfo)throws UnsupportedEncodingException
    {
        return reportService.getSecurityReport(client,check,checkInfo,false);
    }

    /**
     * @auther wenyihan
     * 生成报告
     * @date 14:49 2019/9/5
     * @param recordId
     * @return java.lang.String
     */
    @ResponseBody
    @PostMapping("/getScslReport")
    public String ScslReport (String recordId, String checkId , String projectId) throws UnsupportedEncodingException {
        String result = "";
        return result = actualMeasureService.newMeasureReport(recordId,checkId,projectId);
    }
    /**
     * @author xiaxing
     *生成单台设备报告
     * @date 2021/3/31 9:52
     * @param: (projectId,checkId,checkPart,fourthId,reportType)
     * @return java.lang.String
     */
    @ResponseBody
    @PostMapping("/getEquipReport")
    public String generatingEquipmentReport(int projectId, int checkId, String checkPart, int fourthId) throws UnsupportedEncodingException,Exception{
        String result = "";
        if (newprefixsystemMapper.getName4ByName4Id(fourthId) .equals("塔式起重机") ) {
            //塔式起重机报告
            result = reportService.equipTowerReport ( checkId,  projectId,  checkPart,  fourthId);
        } else if (newprefixsystemMapper.getName4ByName4Id(fourthId).equals("施工升降机")
                ||newprefixsystemMapper.getName4ByName4Id(fourthId).equals("物料提升机")) {
            //施工升降机报告
            result = reportService.constructionLifterReport(checkId,  projectId,  checkPart ,fourthId);
        } else if (newprefixsystemMapper.getName4ByName4Id(fourthId).equals("门式起重机")) {
            //门式起重机报告
            result = reportService.gantryCraneReport(checkId,  projectId,  checkPart ,fourthId);
        } else if (newprefixsystemMapper.getName4ByName4Id(fourthId).equals("流式起重机")) {
            //流式起重机报告
            result = reportService.streamingCraneReport(checkId,  projectId,  checkPart ,fourthId);
        }
        else if (newprefixsystemMapper.getName4ByName4Id(fourthId).equals("附着式升降脚手架")) {
            //附着式升降脚手架报告
            result = reportService.insertedLiftScaffoldReport(checkId,  projectId,  checkPart ,fourthId);
        }
        else if (newprefixsystemMapper.getName4ByName4Id(fourthId).equals("高处作业吊篮")) {
            //附着式升降脚手架报告
            result = reportService.highWorkHangingBasketReport(checkId,  projectId,  checkPart ,fourthId);
        }
        return result;
    }

}


